package com.xy.model;

import lombok.Data;

@Data
public class RestfulResult<T> {
		private int status = 1;

		private String errorCode = "";

		private String errorMsg = "";

		private T resultBody;

		public RestfulResult() {
		}

		public RestfulResult(int status) {
				this.status = status;
		}

		public RestfulResult(int status, T resultBody) {
				this.status = status;
				this.resultBody = resultBody;
		}


		public RestfulResult(int status, String errorCode, String errorMsg) {
				this.status = status;
				this.errorCode = errorCode;
				this.errorMsg = errorMsg;
		}

		public static RestfulResult success(Object data) {
				return new RestfulResult<>(1, data);
		}

		public static RestfulResult success() {
				return new RestfulResult<>(1);
		}

		public static RestfulResult failed() {
				return new RestfulResult(0);
		}

		public static RestfulResult failed(String errorCode, String errorMsg) {
				return new RestfulResult(0, errorCode, errorMsg);
		}
}
